package com.engine.jz.util;

import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;

import java.util.Map;

/**
 * @version 1.0
 * @Title ecology-9
 * @Company 泛微软件
 * @CreateDate 2024/11/27
 * @Description 天波工具类
 * @Author AdminZm
 */
public class TelpoUtils {

    BaseBean baseBean = new BaseBean();

    /**
     * 远程查询设备考勤事件
     */
    public String queryTelpoMj(String ip, Map<String, Object> paramMap, String taskId) {
        String result = null;
        baseBean.writeLog("queryTelpoMj start.");
        RecordSet rs = new RecordSet();
        try {
            String url = "http://" +ip + ":1820/Face/sendControl";
            result = HttpRequest.post(url)
                    .header(Header.CONTENT_TYPE, "application/json")
                    .body(JSONObject.toJSONString(paramMap))
                    .timeout(20000)
                    .execute().body();
            rs.executeUpdate("UPDATE uf_kqsjtbjlb SET qqxy = ? WHERE rwid = ?", result, taskId);
            baseBean.writeLog("queryTelpoMj end.");
            return result;
        } catch (Exception e) {
            rs.executeUpdate("UPDATE uf_kqsjtbjlb SET qqyc = ? WHERE rwid = ?", e.getMessage(), taskId);
            baseBean.writeLog("queryTelpoMj error:" + e);
        }
        return result;
    }
}
